Recently I want to use sass to implement a dark theme in my ts test project but IDK why I face this issue
Error in plugin "sass"
Message:
src/Assets/Sass/main.scss
Error: Invalid CSS after "...lude animations": expected "}", was ".theme-change;"
on line 6 of src/Assets/Sass/main.scss
>> @include animations.theme-change;
-------------^
in my main file main.scss i @use my partials and @include @mixin like this:
@use 'colors';
@use 'animations';
@use 'theme';
body {
@include animations.theme-change;
&[data-theme='light'] {
@include theme.mode(colors.$light, colors.$dark);
@include theme.components(colors.$light, colors.$dark);
}
&[data-theme='dark'] {
@include theme.mode(colors.$dark, colors.$light);
@include theme.components(colors.$dark, colors.$light);
}
}
These are my partial
in side all of them there is one or two @mixin only
_animations.scss
_colors.scss
_theme.scss
_theme.scss includes theme styles and components
@mixin mode($theme-bg, $theme-color) {
background: $theme-bg;
color: $theme-color;
}
@mixin components($theme-bg, $theme-color) {
.container {
width: 100vw;
height: auto;
}
}
_colors.scss is just some variables holding theme colors
$light: #fff;
$dark: #232323;
$primary: #FFBD07;
$secondary: #2b2d42;
$tertiary: #edf2f4;
$quaternary: #e5383b;
_animations.scss have just a @mixin
@mixin theme-change {
transition: color, background cubic-bezier(0.68, -0.55, 0.27, 01.55) 420ms !important;
}
.sass files are for stylus syntax, use .scss as the extension instead
.container {
background-color: #f5f5f5;
}
.container
background-color: #f5f5f5
as you can see SASS doesnt use braces and semicolons